#ifndef _DynamicLengthSerializer_H_
#define _DynamicLengthSerializer_H_

#include "DynamicLengthPool.h"
#include <vector>
#include <stack>

class CDynamicLengthSerializer : public ISerializer
{
public:
	CDynamicLengthSerializer(std::vector<char>& rVec, bool bWriteMode);
	virtual ~CDynamicLengthSerializer(void);
public:
	virtual bool	IsWriteMode();

	virtual void	Serialize( bool& rBoolData );

	virtual void	Serialize( short& rShortData );
	virtual void	Serialize( unsigned short& rShortData );
	virtual void	Serialize( char& rCharData ) ;
	virtual void	Serialize( unsigned char& rCharData ) ;
	virtual void	Serialize( int& rIntData ) ;
	virtual void	Serialize( unsigned int& rIntData );
	virtual void	Serialize( __int64& rIntData );
	virtual void	Serialize( float& rFloatData );
	virtual void	Serialize( double& rDoubleData );

	virtual void	Serialize( std::string& strData );
	virtual void	Serialize( char* cpChars,int nSize );

	virtual unsigned int    Begin(void *key/* = 0*/);
	virtual unsigned int    End(void *key/* = 0*/);

private:
	bool	m_bWriteMode;
	CDynamicLengthPool m_dynaPool;

	std::stack<std::pair<unsigned int, void*> > m_stackCurBegin;
	std::stack<std::pair<unsigned int, void*> > m_stackCurEnd;

};

#endif//_DynamicLengthSerializer_H_
